package edu.codink.xq.center.util;

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;


public class Config
{
   
    private static Logger logger;
    public static final String DB_URL;
    public static final String DB_DRIVER;
    public static final String DB_USER;
    public static final String DB_PASSWORD;
     public Config()
    {
    }

    static 
    {
        Properties properties = new Properties();
        try
        {
            properties.load((new Config()).getClass().getResourceAsStream("/jdbc.properties"));
        }
        catch(IOException e)
        {
            logger.error("读取配置文件失败", e);
            throw new RuntimeException("读取配置文件失败", e);
        }
        try
        {
        	DB_DRIVER = properties.getProperty("jdbc.driverClassName");
        }
        catch(Exception e)
        {
            logger.error("加载数据库驱动失败", e);
            throw new RuntimeException("加载数据库驱动失败", e);
        }
        try
        {
            DB_URL = properties.getProperty("jdbc.url");
        }
        catch(Exception e)
        {
            logger.error("加载数据库地址失败", e);
            throw new RuntimeException("PROPERTIES INIT FAILED", e);
        }
        try
        {
        	DB_USER = properties.getProperty("jdbc.username");
        }
        catch(Exception e)
        {
            logger.error("加载数据库用户名失败", e);
            throw new RuntimeException("加载数据库驱动失败", e);
        }
        try
        {
        	DB_PASSWORD = properties.getProperty("jdbc.password");
        }
        catch(Exception e)
        {
            logger.error("加载数据库密码失败", e);
            throw new RuntimeException("加载数据库驱动失败", e);
        }
    }
}
